<template>
    <div class="container">
        <EditTableCommon :prop-json="propJson" :common-param="commonParam" :table-data="tableData.variableValue"/>
    </div>
</template>

<script>
import EditTableCommon from '@/components/lowcode/extension/components/EditTableCommon'
import {getCommonParamInfo, getCommonParamObj} from "@/utils/commonParamUtil";

export default {
    name: "EditableTableListComponent",
    props: ['propJson', 'commonParam'],
    components: {
        EditTableCommon
    },
    computed: {
        tableData() {
            if (this.propJson.editFlag) {
                return []
            }
            let dataList = getCommonParamInfo(this.commonParam, this.propJson.tableDataVariable)
            // 为每一行数据添加一个序号
            for (let index = 0; index < dataList.length; index++) {
                let info = dataList[index]
                info["ywuEditorInnerId"] = index + 1;
            }
            let paramObj = getCommonParamObj(this.commonParam, this.propJson.tableDataVariable);
            if (!dataList) {
                paramObj.variableValue = [];
                return paramObj
            }
            paramObj.variableValue = dataList
            return paramObj;
        }
    }
}
</script>

<style scoped lang="less">

</style>